Feature: The application gives a proper error when opening a corrupted xml file

  Scenario: When I open an empty XML file I get a no declaration error
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/empty_file.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The declaration is missing."
    Then the output should contain "Opening file input_files/empty_file.xml cancelled."
    And the output should not contain "FILE MENU"

  Scenario: When I open a XML file with no declaration I get a no declaration error
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/no_declaration.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The declaration is missing."
    Then the output should contain "Opening file input_files/no_declaration.xml cancelled."
    And the output should not contain "FILE MENU"

  Scenario: When I open a XML file with invalid declaration I get an invalid declaration error
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/incorrect_declaration_01.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The declaration is invalid."
    Then the output should contain "Opening file input_files/incorrect_declaration_01.xml cancelled."
    And the output should not contain "FILE MENU"
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/incorrect_declaration_02.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The declaration is invalid."
    Then the output should contain "Opening file input_files/incorrect_declaration_02.xml cancelled."
    And the output should not contain "FILE MENU"

  Scenario: When I open a XML file with no root tag I get a no root tag error
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/no_root_tag.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The root tag is missing."
    Then the output should contain "Opening file input_files/no_root_tag.xml cancelled."
    And the output should not contain "FILE MENU"

  Scenario: When I open a XML file with a malformed tag I get a malformed tag error
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/syntax_error_01.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The XML file has a malformed tag."
    Then the output should contain "Opening file input_files/syntax_error_01.xml cancelled."
    And the output should not contain "FILE MENU"
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/syntax_error_02.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The XML file has a malformed tag."
    Then the output should contain "Opening file input_files/syntax_error_02.xml cancelled."
    And the output should not contain "FILE MENU"

  Scenario: When I open a XML file with unbalanced tags I get an unbalanced tags error
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/unbalanced_tag.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The XML file has unbalanced tags."
    Then the output should contain "Opening file input_files/unbalanced_tag.xml cancelled."
    And the output should not contain "FILE MENU"

  Scenario: When I open a XML file with multiple root tags I get a multiple root tags error
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/multiple_root_tag.xml"
    And I close the stdin stream
    Then the output should contain "ERROR while building XML from file: The XML file has multiple root tags."
    Then the output should contain "Opening file input_files/multiple_root_tag.xml cancelled."
    And the output should not contain "FILE MENU"